package com.training1.core.web.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.training1.core.common.controller.BaseController;


@Controller
@RequestMapping("cultivate")
public class CultivateController  extends BaseController{
	
	//@Resource
	//private CultivateService tUserService;
	
	/**
	 * 管理员账号管理
	 * @return
	 */
	@RequestMapping("functionList")
	public String functionList(){
		return "liyunlei/functionList";//清单
	}
	
	@RequestMapping("operational")
	public String operational(){
		return "liyunlei/operational";//运算符
	}
	
	@RequestMapping("stringDispose")
	public String stringDispose(){
		return "liyunlei/stringDispose";//字符串处理
	}
	
	@RequestMapping("jQueryHTML")
	public String jQueryHTML(){
		return "liyunlei/jQueryHTML";//jQuery HTML操作 - 获取、设置、添加、删除
	}
	
	@RequestMapping("jQueryDOM")
	public String jQueryDOM(){
		return "liyunlei/jQueryDOM";//jQuery DOM节点操作 - 父节点、子节点、兄弟节点
	}
	
	@RequestMapping("jQueryArray")
	public String jQueryArray(){
		return "liyunlei/jQueryArray";//jQuery 数组、集合的操作 - 添加、遍历、删除
	}
	
	@RequestMapping("search1")
	@ResponseBody
	public String search1(String condition1,String operational1,String condition2){
		boolean b1 = Boolean.parseBoolean(condition1);
		boolean b2 = Boolean.parseBoolean(condition2);
		Boolean result1 = null;
		if("&&".equals(operational1)){
			result1 =  b1 && b2;
		}else if("||".equals(operational1)){
			result1 =  b1 || b2;
		}
		return result1.toString();
	}
	
	@RequestMapping("search2")
	@ResponseBody
	public Integer search2(Integer condition3,String operational2,Integer condition4){
		Integer result2 = null;
		if("&".equals(operational2)){
			result2 =  condition3 & condition4;
		}else if("|".equals(operational2)){
			result2 =  condition3 | condition4;
		}
		return result2;
	}
	
	@RequestMapping("split")
	@ResponseBody
	public List<String> split(String str1,String str2){
		if(str2 == "" || str2 == null)
			str2 = " ";
		List<String> list = new ArrayList<>();
		String[] arr =  str1.split(str2);
		for (String s : arr) {
			list.add(s);
		}
		return list;
	}
	
	@RequestMapping("substring")
	@ResponseBody
	public String substring(String str,Integer begin,Integer end){
		return end == null?str.substring(begin):str.substring(begin,end);
	}
	
	@RequestMapping("concat")
	@ResponseBody
	public String concat(String str1,String str2){
		return str1.concat(str2);
	}
	
	@RequestMapping("indexOf")
	@ResponseBody
	public Integer indexOf(String str4,String str5){
		return str4.indexOf(str5);
	}
	
	@RequestMapping("endsWith")
	@ResponseBody
	public Boolean endsWith(String str6,String str7){
		return str6.endsWith(str7);
	}
	
	@RequestMapping("replaceAll")
	@ResponseBody
	public String replace(String str8,String str9,String str10){
		return str8.replaceAll(str9,str10==null?"":str10);
	}
	
	@RequestMapping("toLowerOrUpperCase")
	@ResponseBody
	public String toLowerCase(String flag,String str11){
		if("toUpper".equals(flag)){
			return str11.toUpperCase();
		}else{
			return str11.toLowerCase();
		}
		
	}
}
